Item rotation code improved