mg replace and form submit fix