changes to detection code