(the last "fi" refers to the "if" 20 lines above)