make two classes that were very similar into one template