working on the integral calculation