Removed duplicate code from submit.js