first version of fast rescan. can be made faster