finally working chasing algorithm based on a* but doesnt give shortest