clear function updated