Updated clear function