Welcome to Stack Overflow! @David, the question needs work before it's suited to
Code Review. You could have pointed the asker at
A guide to Code Review for Stack Overflow users, as some things are done differently over there - e.g. we need a good description of the
purpose of the code to give context, and question titles should simply say what the code
is for (the question is always, "
How can I improve this?"). It's important that the code works correctly; include the unit tests if possible. —
Toby Speight 44 secs ago