Fixed null issue in metrics calculator