Fix for Issue #3197

Check if variable isset to avoid undefined error.