Fixed Dijksta implementation