metaprogramming example from http://goo.gl/fmIh4T