Wrote logic for max2