implement dijkstra, but needs optimization
dijstra is not fast enough