Adding the observer pattern code