refactoring type checker