fix state undefined