Improve type checking