as far as I can go without a proper tree for global loops