re-fixed strcpy/strcat bug by adding pre-realloc if necessary