fixed rotation bug (devide by zero issue)
code cleanup