add the buffer clear helper function