wrapped do/while section of submit function with a counter to give a hard limit to do/while