One good thing to do, before you ask some question is to maybe try and find an editorial or explore the comments section ( if there is such a thing ), and try to figure out if they have mentioned a solution. On the problem page, you can see the heading. They have written it in bold also, and provided link to a blog. Maybe you should read that.
Also, another suggestion to you is, avoid pasting your code in your post. Usually, people don’t like reading long posts. So, mostly people will ignore your post (unless you’re an editorialist xD ). But, seriously, no one likes to read code in a post. You should try to put your code online somewhere, and share the link. There are many such websites, and you can find anyone you like. Some examples are ideone and pastebin.
And finally, I have explained the same question here. So maybe, if you don’t find an editorial or blog etc, try to search on Discuss forums. Usually problem tag should give you many results, if there is ambiguity in question, or many people have doubt in it.
Sorry for the long post ( I know no one likes long posts ). Cheers!