improved patient data update code