Added NPE check