Lots of duplicated code here that would go away if we moved it into the `checkfperr` function.