Simplifying the array code