fixed cases that could lead to NPE