Improving our code with events