moved connection methods into it's own method