and here begins the rewrite