refactor lib structure