Bug fix in output generation