finished backtracking and test direction function, all working as expected