Fix bug to calculate duration from timestamps