fix connection being made too soon