Fix template for not to crash when an unexpected state name appears