fix page crash bug, add checking nil condition