Use memmove and memcpy instead of for loop