Removes redundant 'end'