Can you put this chunk of added code into its own function too?