bug fix on testing if the previous tag was found