Fix loop variable type