refactor resource allocation in arrays