Used metaprogramming to combine all functions