Optimizing xreferee with elemIndex