Fix loss calculator