refactor to remove negative match and clean up iterator