changed all for loops to not declare int inside