added detect device mechanism.