add main JS function to calculate payments