refactor timer