implemented backtracking loop and hooking all the necessary components