Cleaned up needToRotate function. Fixed some indenting.