Added calculation for max_amount