Additional NPE check added