optimized some metric calculations