bounds checking when setting max and min values