Updated order logic

Worked up ordering logic, next step is to figure out aggregation