improve deleting buffer and remove useless function