for do
 for do
  if then
  
  if then
  
  
  
 if not be filled with service group then
return
Algorithm 2