Re-factor by turning the two separate code blocks into separate functions. While this isn't strictly necessary, it demonstrates the preferred C++ practice of making each separable activity a separate function. In the long run, this improves the maintainability of the code.