replace type code with polymorphism