middle of a horrendous rewrite