updated quilb.js
fixed bug and refactored code