Improve save and delete logic