fixes to the add_gw function