Update library.js

It actually doesn't work in this state.
I had to add some tweaks.