trying to get the loop right