fix missing end and increment