simplifying the example, and adding debug output