You could move this into the loop condition (and the return after the loop maybe?)