refactoring type checking to make converting to dataflow graph easier