refactor set_type