A little hard to understand, but I think I got there in the end :P

Thanks for the link!