Changed the code to directory based data collection