observer pattern refactoring