Fixed reuse of variable in error checking code