simplified catamorphism and made the usage of it more OO like