Typo fix: idx>len(mod_t) should be >=