duration function-some changes