nit: `d` ==> `device`, to make this easier to read