Optimized the code for adding tics