refactor the time helper