implemented typechecker