Move this whole `if` block inside the previous `if` after the `for` block