add clear method
refactor -> change to be thread safe