Add error handling for inserting data to database.
Change insertion to reflect updated database design