working but n times runs instead of backtracking