improve type fn