fixed a finalize bug