Fix 'pw' variable name in error handling