Added min and max function