cleaning up flattenAndPutDataInFolder method