edit code only when fetch is successful