computing duration in seconds