Add global loss computation