fixed a typo and simplified logout codes