added validation for the input fields