finalizing functionality