make a trough upgrade that allows your cows to eat for themselves so that none of them starve because of stacking
and add a priority system where if one cow has less hunger than the other it has higher priority to be given the wheat (if a cow is full/has lots of hunger they don't need any)