optimized target match check

moved out of foreach loop, had no place there. it was a pointless check
during each neighbour that had nothing to do with neighbour