First working version of TypeCheck