modified loop to send idDevice-idService