generating results correctly taking order into account