implements the rotating array