put EC before output
Merge pull request #991 from huili2/reorder_output_EC

put EC before output