Add null check

Fix Cannot read property '0' of null