fixed error handling, added user name validation