move declaration out of loop