added finalize mechanism