Added rotatin algorithm