write observer pattern