refactor type code