tidy up _filter_line a bit