Refactor array creation