Update lib.js

fix use of majorArr, first idx...