refactoring array