lib refactoring