Refactor parseArray