Fixing bugs in output