use class and function to loop over files