I would add a `trim()` around `$device` to ensure there aren't blank spaces tripping it up.