make sure to remove trees between matrices