Added rotation. Encapsulated in a function.