corrected minmax call to use return value of apply