fixed shaking distance logic