Added checks for maximum and minimum values.