detection algorithm improved