fix bug with files array being reset