fix a bug which uses int in for loop