refactoring to a baseFileName that can work in the browser, for later