convert unlock code block repeats to for loop