improved capping calculation