solved the realloc function