fixed logical error in output formatting