moved methods set to for loop scope to avoid side effects