optimization with memcpy