Corrected rotation matrix function (again)