Added check for NPE