added validation and login function