updated to work with file saving