refactor all lib