Saving index instead of an element reference