Added rotateArray helper function.