rewrite: got a first pass, rewritting, tests first