use xstrdup instead of xmalloc + strcpy