Fixed bug in rotation code