Added validation for input.