added validation and removed alert code