Form gets stuck after hitting the submit button