Refactor connection to build once per class