Add function to retrieve device from an element