fixed errors in computing metrics.