simplify timer implementation, using anonymous function