implemented save functionality