Fix functions to calculate value to be pay