implementing th UpdateUi method more genericlly