changed to use fmax