optimized amount_to_pay