Fix for integral calculation