Refactored code to include timeutils module