Refactored clear function and added user notifications