fixed incorrect index for $array_ref