Migrate code to Observer pattern