fix potential bug with clear function