Refactor using an array