fixed an error with the values being used for calculating