clean up tag filtering code
add comments to filter code