Fixed the null pointer sometimes getting on device