refactored the code for finding major and minor ticks positions