only has forward lookup, need to add backward
works fine for backward retreat, but Time Limit Exceeded