fixed a bug with clear function