implemented timer function