refactor of devices management