memcopy and memmove is very inefficient