reworked generate output order