refactor some libs