Modified to use quaternion