code sample for observer patern