Reworked preferred neighbor algorithm