Fix possible bug when user logs out