fixed some 'end'