Refactored out submit code to it's own function so I can debug it.