refactor timer.js