properly check type
Fixes, should be working properly now