Added code to limit the amount of files generated