save functionality back-end