rewrite type system in a new version