Change index variable to idx