refactored code for drawing major and minor ticks