update the code to save yi an to database