fix missing end bug