Trying to fix for loop