refactored the observe method to use an anonymous function instead of a Trait