Ajusted code to process mutiple metrics at once