update form api with a better code