Clean code and change algorithm in DeviceTableViewPart and NavigationViewPart