moved tag implementation from controller to model