added check for circular dependencies