save changes before commiting