handle form submitting and saving