handle sub directories and multiple directories