changing to typeof instead of instanceof