Update library and simplify the code