several changes to implement better error handling and user authentication methods