basic detection code