save and discard functionality added