fix the save middleware