Moving repeating code into variables