Fix integral calculation