Add check SUDO mode. Small refactoring.
Add check SUDO mode. Small refactoring.