Refactoring to types