Modified to handle different data file suffixes