Eliminating custom ‘toType’ method in favor of instanceof