Fixed NPE issue