Abstracted connection code into separate module