fixed the null issue with state