Dapple['maker-otc'].objects.otc.offers(idx.toNumber(), (error, data) => {
        if (!error) {
          const offer = Offers.findOne({ _id: idx.toString() });

          if (offer) {
            const [, , , , , active] = data;
            Offers.syncOffer(idx.toNumber());
            /**
             * When the order matching is enabled there is check on the contract side
             * before the creating new order.
             * It checks if the new order is about to match existing one. There are couple of scenarios:
             *
             *  - New order is filled in completely but the existing one is completed partially or completely
             *    = then no order is actually created on the blockchain so the UI has offer is transaction id only.
             *
             *  - New order is not filled in completely but fills the existing one completely
             *    = then new order is created with the remainings after the matching is done.
             *
             * Transaction hash of the event in the first case scenario, corresponds to the transaction hash,
             * used to store the offer on the client. In order to update the UI accordingly, when the first scenario is met
             * we used the transaction has to remove the new order from the collection.
             * */
            Offers.remove(result.transactionHash);
            if (!active) {
              Offers.remove(idx.toString());
            }
          }
        }
      });
 Dapple['maker-otc'].objects.otc.LogSortedOffer((err, result) => {
   if (!err) {
     const id = result.args.id.toNumber();
     Offers.syncOffer(id);
     Offers.remove(result.transactionHash);
   } else {
     console.debug('Error placing new sorted offer!', err);
   }
 });
 Dapple['maker-otc'].objects.otc.LogItemUpdate((err, result) => {
   if (!err) {
     const id = result.args.id.toNumber();
     Offers.syncOffer(id);
     Offers.remove(result.transactionHash);
     if (Session.equals('selectedOffer', result.transactionHash)) {
       Session.set('selectedOffer', id.toString());
     }
   }
 });
  const getNextOffer = (id, error) => {
    if (!error) {
      const loaded = Session.get('loadingCounter') + 1;
      const total = Session.get('offersCount');
      Session.set('loadingCounter', loaded);

      if (loaded === total) {
        Offers.syncOffer(id.toString(10));
      } else {
        Offers.syncOffer(id.toString(10), total);
      }
      Dapple['maker-otc'].objects.otc.getWorseOffer(id.toString(10), (err, nextId) => {
        if (!err && !nextId.eq(0)) {
          getNextOffer(nextId);
        }
      });
    } else {
      console.debug('Trouble getting next offer: ', error);
    }
  };
 Dapple['maker-otc'].objects.otc.last_offer_id((err, n) => {
   if (!err) {
     const lastOfferId = n.toNumber();
     console.log('last_offer_id', lastOfferId);
     if (lastOfferId > 0) {
       Session.set('loading', true);
       Session.set('loadingProgress', 0);
       for (let i = lastOfferId; i >= 1; i--) {
         Offers.syncOffer(i, lastOfferId);
       }
     } else {
       Session.set('loading', false);
       Session.set('loadingProgress', 100);
       Session.set('loadingBuyOrders', false);
       Session.set('loadingSellOrders', false);
     }
   }
 });