Replace endif with endfor