Refactor with arrays