move common code to doi_form