Yep. Just did some test (with the explorer) on my solution and it works perfectly well.
I think we were saying the same thing but coded differently.
However, as I said before, I always have some delisted stocks with no GICS number.
Therefore the results of a strategy using this snippet will have some bias (but I think it should be small).