updated the code to add to the database