modified the order and sale order logic