add directory scan function to find valid files