Fixed bug in tick counter