remove memmove, take a loop instead