completed tag detection algorithm