Chnaged the search for device loop