bug fix to buildmodel