Revised rotation code