new code for quaternions