it almost generates working code, almost