small refactorings to connection