Factor out subscription code