Added generic detect method.