access array with index instead of array_pop