added npe checks