refactor type stuff