8.12-before
refactor
replace type code with polymorphism