refactored main array generator