change to realloc for 2% speed increase