ObstacleLoss: eliminated code duplication.