Refactoring connection initialization out into a method.