implemented min max