little refactory on metrics calc