Couldn't we move this condition outside the loop?