lib: refactoring