refactored some of the onDraw function