Fix TypeError: Undefined order, cannot get items from dict #1326