Refactored compact_order, it now has less code. Same functionality.