updated code to retrieve data to new directories