added detection code