fix timer function