some code examples used in my blog http://www.benharrington.com/blog/