refactoring
optional saving directly to local file