Refactor to use the power of metaprogramming