better form code to avoid duplicated submission