throwing error if circular reference is found