Fix nil pointer exception

Fix nil pointer exception