Maximizing foraging success: the roles of group size, predation risk, competition, and ontogeny