Fixed casting null issue