refactor gmetric.py