start of submit function