fixed few bugs within the model