refactor device admin code