Move code out of the  statements into their own functions