refactor and add support for new types