beginnings of a* algorithm