Implemented refactored code for Observer Pattern