Here's the code. BTW check out the story if you want to.