Cleaned up duration calculation method.