fixed bug in realloc