handle multiple directories and subdirectories