update form and improve overall code