fixed 'clear' functionality to prevent crashes