Added code to perform calculation prior to submit.