Fixed bug making output invalid