added clientside logic for saving