• It seems I can not post code to the site, I wanted to post a more generic solution