Used dicts to track dist and nearest