Refactoring including Observer design pattern.