Refactor form and live preview