remove the last 'end'