refactor duplicate array code in favor of getArrayOfSize