rewrite library for more OO