lib: refactor