corrected logic for device verification.