adding max function