fixed a bug in clear() function