A complete  rewrite of the generator