Refactor form rendering