extract observer code into a module