Faster neighborhood code