added validation for inputs