move tag grepping to the model