finally a better C-g solution