fix insert function
use realloc instead of malloc
best version so far