typo causing bug in conversion of idx to matrix if idx is not a matrix in in-line function permFun