restructure timer logic