fixed logout and exception handling