A Star algorithm, rewrite