Fixed device_id check (issue #2479)