lastPos overlaps with posWithinRange(), so remove it