Fix variable names in innermost loop