Added check for circular dependencies