for-loop rotations begin and end point reduced by 1 each to prevent index out of bounds