fixed bug in analyse_sg