Move the getConnection function out of the constructor as it's not really a part of the returned function