protected function update($step)
    {
        $objectStateService = $this->repository->getObjectStateService();

        $groupsCollection = $this->matchObjectStateGroups('update', $step);

        if (count($groupsCollection) > 1 && isset($step->dsl['references'])) {
            throw new \Exception("Can not execute Object State Group update because multiple groups match, and a references section is specified in the dsl. References can be set when only 1 state group matches");
        }

        if (count($groupsCollection) > 1 && isset($step->dsl['identifier'])) {
            throw new \Exception("Can not execute Object State Group update because multiple groups match, and an identifier is specified in the dsl.");
        }

        foreach ($groupsCollection as $objectStateGroup) {
            $objectStateGroupUpdateStruct = $objectStateService->newObjectStateGroupUpdateStruct();

            if (isset($step->dsl['identifier'])) {
                $objectStateGroupUpdateStruct->identifier = $this->referenceResolver->resolveReference($step->dsl['identifier']);
            }
            if (isset($step->dsl['names'])) {
                foreach ($step->dsl['names'] as $languageCode => $name) {
                    $objectStateGroupUpdateStruct->names[$languageCode] = $name;
                }
            }
            if (isset($step->dsl['descriptions'])) {
                foreach ($step->dsl['descriptions'] as $languageCode => $description) {
                    $objectStateGroupUpdateStruct->descriptions[$languageCode] = $description;
                }
            }
            $objectStateGroup = $objectStateService->updateObjectStateGroup($objectStateGroup, $objectStateGroupUpdateStruct);

            $this->setReferences($objectStateGroup, $step);
        }

        return $groupsCollection;
    }