refactor lib