Rearrange tag filter code

Change-Id: I715ca40aa7c09c73fbd8d1a8c815253c22f947b2
progress

Change-Id: Ief4c5f36e51b7e6f6a12b21a31146e5aca4a8205