replace the observer pattern with a simple update function