NW changed, added backtrack method