optimize the scanning process