Refactoring of array generation