neighbor algorithm and map working