added check to prevent circular dependencies