pass by ref workaround for array_pop