realloc improvement