Copied target-loss code to calendar