Refactoring array usage