refactoring, connectsession stuff