separate sanity check function