Handle setting maximum and minimum properly