Updated connect insertion logic