fix G-algo, added logging