added validation for the input