created logout and error handling