updated save functionality