edited rotation code