Replace the usage of Array.indexOf