safe type check