metaprogramming for similar methods