outsourced some parts of onUpdate into new methods that will be called from onUpdate()