add sanity check and few definitions