Factor out worker queue code from sync function