complete the submit function