I implement a bidirectional scanning, but the performance is not good. How to improve it? Thanks very much.