should be using memmove and not memcpy.