updated detect method