add clear and write functions