added variable sum to final calculation