@Mast I mislinked the SO duplicate in my custom flag. I felt like only close voting it was maybe inappropriate for a cross site duplicate. The code works in the sense that there is no syntax error, but it doesn't do what the OP expects it to do.
I did downvote it as well, but I felt a custom flag was more appropriate for getting the question closed (that might have been my misunderstanding, I am not very active on code review till now and meta doesn't seem to have all the answers :) )