FIX: add breaking condition in calculation of integral