fix form state handling