Rewrite type checking