finish save functionality