fixed stack seg fault in clear()