Updated timer function