Noting that speaks of "after the plague" immediately before reporting that God ordered the census, a Midrash concluded that whenever the Israelites were struck, they needed to be counted, as a shepherd will count the sheep after a wolf attacks. Alternatively, the Midrash taught that God ordered Moses to count the Israelites as Moses neared death, much as a shepherd entrusted with a set number of sheep must count those that remain when the shepherd returns the sheep to their owner.