updated the code with the timerdelay