handling a possible NPE