rewriting factories