Added a NPE check