Holy shit that was a stupid rewrite.  This should work.