Update timer.cpp

Adding functionality using the state of timer