Explaination can be found here. Source code

My Friends