refactor connection maintenance into a util class