function for rotating (contributes to #22)