Fixed some bugs because of changing in the model