fix bugs in BOW extraction