added duration calculation