re-write of the library