refactor array to work with index element and better index discovery