tried a simpler approach. full rewrite.