improved type checking