Optimize file scanning