I personally don't like the variable name `tmp`.  Why not changing it to `endpointIdx` and `_endpointIdx` to `_endpointIdxs` ?