Dijstra mostly working
TODO: factory to handle error and return null window if necessary