It seems unnecessarily inefficient to transform the whole array here and then only use one index before throwing it away.  I suggest you combine with the code below, to only convert the indexed part.