error handling and save functionality working