code now parses and outputs somewhat correctly