Fixed bug for NPE