add buildModel function