started rewrite of library