adding npe check