generates working code. Need some prettyprinting modifications