changed endif to endfor