throwing an error when there is circular reference