max function added