fixed 'end' error