device escalation plus more refactoring