Rewrite creating class by using type()