made the function iterative
data files