deviceRoot assignment should be done before the loop.