Refactoring connection manager