small refactoring at rotateNearestNeigbour