bugfix for filename not updating. Still needs refactor