refactor array