Implement sanity check

Untested but should work