Starting to convert some button updating code to a function