Fix bad var in error checking