Changed first approach to a more general MS-specific approach.
Suggested by @SpecLad