quick refactoring of time handling