move progress calc to function