fixed bugs; added code to inspect pattern tags