Fix the sign issue by reordering the operations. Use memcpy instead