Modified to generate the form dynamically