fix some bugs in model