fixed 'end' in wrong place