another solution to the exercise, using signals
added a few comments