fix a bug in BM match