making UpadateUi method to be thread safe