What is this strange loop doing?