Exactly. It's risk management. This is referred to as a general anti‑avoidance measure.
The issue of whether a planning operation respects the spirit of the law is in large part a matter of interpretation. Like I said, there have been many cases like this and there is some case law to work with. All partners rely on an experienced team to help them get a good idea of the situation or issue at hand.