change instanceof to typeof