reorganize and optimize build