Connection refactoring