revert the previous changes, breaks on circular structures, will try something else later