Refactor code for duration representation