Adding NPE check