Cleaned up the logic in output_proc a tad