naive rewrite attempt, untested