sanity checks to prevent null pointer exception