Issue 4: fix NPE.