fixed dijstra's max problme