From http://stackoverflow.com/questions/9025805/getting-a-reference-to-the-last-item-of-an-array