MAX and MIN search working