Fix incorrect attribute check

(cherry picked from commit 9bee3e1f5135a97ac683f5e6a7383b8dc2bd0ccc)