Reducing writing of map to file