Updated logic that saves files to server