fixing bugs in the analyze_metric-function