Finished algorithm based on reucrring conflicts