= type inference algo refactoring