fixed a bug in the mismatch algorithm