Added boolean check for subfolders