As I told the original author, several of the statements below should come before the loop.