added more sanity checks