update the rotation logic