Can you tell me why this works (so I can learn)? Should it be in a separate function? I don't know if it gets used anywhere else.