Logic added to hazard detection.