Compartmentalize Cod a bit
refactor connection