refactor type divination