move model update logic from view to model