If it works for you every time you need it to and it does just what you need without importing a bunch of stuff you don't, then it's the best solution. I only raise the issue of it being used as a general solution because the topic question was pretty broad and I don't want to risk trivializing it for others reading, that's all.
Glad you got it working and thanks for posting your code.