finished data array loop refactoring