lib refactor