Fixed infinite recursion in reslution algorithm