Refactoring and using Observer Pattern