Perhaps some of the common connection code could be abstracted out to a single method?