adjusted scripts to understand subdirectories