updated end to endfor