fix bugs in output