Added logic of rotating