Refactor for arrays