refactor type converter