working demo.  not elegant at all.