fixed wrong memcpy