Implemented multiple devices (at the moment tested with 2)
also added some comments