added withinDistance check