added detect method.