simplifying logic for save button click