Fixed bug with updating the database