found a loop that only will loop while it is not null