removed some unnecessary logouts and started some refactoring