Refactor out the connction to the entrypoint