modified logout logic