metaprogramming to the rescue