Fix TypeError check