added max edge function