refactore builder & fix several errors