correctness checker, no unit tests yet, but seems to work