extract method and reduce number of boolean expressions evalutated in adjacentHashAtBorder