fixed possible logout bugs