Removed unnecessary comparisons in directory scan method