refactor Library impl