Fixed NPE caused by method returning null.