Matt's error checking

quickly put Matt's error checking back in since we lost it in one of the
earlier pushes