refactoring of lib