Improved solving. Still infinite loop because of ordering?