added some modifications for partpayment logic