finished (untested) devicelist function