Why is the form not updating correctly?