fix the bug of only one active device and change the data structure