Changed stopping iteration criteria