added NPE check