logout function fixed