repaired gmg algorithm