improving matching for filtering tags and fixing pep8 warnings