added max and min func