Submit button not working consistently