improved integral calculation