use typeof instead of instanceof