Adds correct connection handling