add error validation and updating model