Wrote sanity check to be used in optimization