refactoring typeof