Refactor type implementation