add check for circular dependency