Fixed the update function for the database.