refactor connection logic so we can support pools and reconnects