extracted a function for updating the UI separately from the model