added some sanity checks