get logic re max/min better