refactor finalization