refactor getDevice