Moving declaration out of for loop as gcc complained.