add max and min (tested)