improved random.sh by prevting direct backtracking