modified so state is updated in database when challenge is updated.