Proper working implementation of memcpy