refactoring to clock.js