Revert avoiding Math.min in indexOf