added clearing logic