Fix edge bug, decompose update_gb function.